package cn.stylefeng.guns.modular.business.controller;


import cn.stylefeng.guns.modular.business.pojo.SubDrawInfoRequest;
import cn.stylefeng.guns.modular.business.service.SubDrawInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 大运图志控制器
 *
 * @author zhangyaowen
 * @date 2021/08/18 14:09
 */
@RestController
@ApiResource(name = "大运图志")
public class SubDrawInfoController {

    @Resource
    private SubDrawInfoService subDrawInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/08/18 14:09
     */
    @PostResource(name = "添加", path = "/subDrawInfo/add")
    public ResponseData add(@RequestBody @Validated(SubDrawInfoRequest.add.class) SubDrawInfoRequest subDrawInfoRequest) {
        subDrawInfoService.add(subDrawInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/08/18 14:09
     */
    @PostResource(name = "删除", path = "/subDrawInfo/delete")
    public ResponseData delete(@RequestBody @Validated(SubDrawInfoRequest.delete.class) SubDrawInfoRequest subDrawInfoRequest) {
        subDrawInfoService.del(subDrawInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/08/18 14:09
     */
    @PostResource(name = "编辑", path = "/subDrawInfo/edit")
    public ResponseData edit(@RequestBody @Validated(SubDrawInfoRequest.edit.class) SubDrawInfoRequest subDrawInfoRequest) {
        subDrawInfoService.edit(subDrawInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/08/18 14:09
     */
    @GetResource(name = "查看详情", path = "/subDrawInfo/detail")
    public ResponseData detail(@Validated(SubDrawInfoRequest.detail.class) SubDrawInfoRequest subDrawInfoRequest) {
        return new SuccessResponseData(subDrawInfoService.detail(subDrawInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/08/18 14:09
     */
    @GetResource(name = "获取列表", path = "/subDrawInfo/list")
    public ResponseData list(SubDrawInfoRequest subDrawInfoRequest) {
        return new SuccessResponseData(subDrawInfoService.findList(subDrawInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/08/18 14:09
     */
    @GetResource(name = "分页查询", path = "/subDrawInfo/page")
    public ResponseData page(String name) {
        SubDrawInfoRequest subDrawInfoRequest = new SubDrawInfoRequest();
        subDrawInfoRequest.setDrawSecond(name);
        return new SuccessResponseData(subDrawInfoService.findAllList(subDrawInfoRequest));
    }

    @GetResource(name = "详情", path = "/subDrawInfo/toDrawReview")
    public ResponseData toDrawReview(String id) {
        return new SuccessResponseData(subDrawInfoService.toSubDrawInfoReview(id));
    }
}